	
	var url = newBaseUrl() + "/targetdata/gettargetdatabyhour"; //初始化url
	var body_h = document.documentElement.clientHeight - document.getElementById("hui-header").offsetHeight - 25; 	//无数据是让容器标签等于屏幕高度
	var dataObj = {};
	
	//清除对比数据
	hui('#clear_L').click(function(){
	    hui.confirm('您确认要这样做吗？', ['取消','确定'], function(){
        	localStorage.removeItem('ID_Contrast');
			if(!localStorage.hasOwnProperty('ID_Contrast')){
				hui.iconToast('清除成功', 'success');
				setTimeout(function(){
					var current = plus.webview.currentWebview();
					var openCurrent = current.opener();
					openCurrent.evalJS("removeStorage()");
					current.close(); 
				},2000)
			}
	    },function(){
	        console.log('取消后执行...');
	    });
	});
	
	
	
	//判断是否已经有需要对比的数据  如果没有 提示无数据
	if(localStorage.hasOwnProperty('ID_Contrast') == false && localStorage.hasOwnProperty('TId_Contrast') == false){
		hui('#chart').css({height: body_h + 'px', overflow:'hidden'});	//无数据显示满屏 禁止滚动
		var p_html = '<p class="no_data">'+ "请添加需要对比的数据!" +'</p>';	// 无数据标签
		hui('#chart').html(p_html);	//添加显示无数据
		hui('#chart').addClass('box1');	//显示无数据文字居中
	}else{// 如果有判断有几个数据 然后做出相应处理
		var ID_con = JSON.parse(localStorage.getItem('ID_Contrast'));		// 获取ID缓存的数据
		console.log(ID_con);
		
		
		console.log(dataObj);
		for(var i=0; i<ID_con.length; i++){
			
			dataObj[ID_con[i].targetcode] = {};
			dataObj[ID_con[i].targetcode].data = [];
			dataObj[ID_con[i].targetcode].time = [];
			dataObj[ID_con[i].targetcode].name = ID_con[i].tName;
			
			refresh(url + '?targetcode=' + ID_con[i].targetcode, dataObj[ID_con[i].targetcode].data, dataObj[ID_con[i].targetcode].time)
		}
		
		console.log(dataObj);
		
		setTimeout(function(){
			var objCode = Object.keys(dataObj);
			var length = Object.keys(dataObj).length;
			console.log(dataObj[objCode[0]].name);
			
			if(length == 1){
				hui('#chart').css({height:'600px'}); //判断有几个图表 设置容器高度
				One_showChart();
			}else if(length == 2){
				hui('#chart').css({height:'600px',background: '#fff'}); //判断有几个图表 设置容器高度
				Two_showChart();
			}else if(length == 3){
				hui('#chart').css({height:'850px',background: '#fff'}); //判断有几个图表 设置容器高度
				Three_showChart();
			}else if(length == 4){
				hui('#chart').css({height:'1000px',background: '#fff'}); //判断有几个图表 设置容器高度
				Four_showChart();
			}else if(length == 5){
				hui('#chart').css({height:'1200px',background: '#fff'}); //判断有几个图表 设置容器高度
				Five_showChart();
			}
		}, 8000)
	}
	
	function refresh(dataUrl, dataArr, timeArr) {
		var startTime = getTaskTime(new Date().setDate(new Date().getDate() - 50)),
			endTime = String(new Date().getFullYear()) + String((new Date().getMonth() + 1) < 10 ? "0" + (new Date().getMonth() +
				1) : (new Date().getMonth() + 1)) + String(new Date().getDate() < 10 ? "0" + new Date().getDate() : new Date().getDate()) +
			'23';
		hui.loading("正在获取数据...");
		hui.get(
		
			dataUrl + '&hourstart=' + startTime + '&hourend=' + endTime,
			function(res) {
						hui.closeLoading();
				var result = JSON.parse(res);
				console.log(result);
				for(var i = 0; i < result.result.data.length; i++){
					var data = result.result.data[i];
					var dt = data.measuretime.substring(0, 13) + '时';
					timeArr.push(dt);
					dataArr.push(data.measuredata);
				}
			},
			function(e) {
				console.log(e)
			}
		)
	}
	function getTaskTime(strDate) {
		//获取前七天日期函数
		var date = new Date(strDate);
		var y = date.getFullYear();
		var m = date.getMonth() + 1;
		m = m < 10 ? ('0' + m) : m;
		var d = date.getDate();
		d = d < 10 ? ('0' + d) : d;
		week = String(y) + String(m) + String(d) + '00';
		return week;
	}
	
	
	//一幅图
	function One_showChart(){
		var objCode = Object.keys(dataObj);
		var length = Object.keys(dataObj).length
		var myChart = echarts.init(document.getElementById('chart'));
		
		option = {
		    title: {
//		        text: Title_Name1,
		        x: 'center'
		    },
		    tooltip: {
		        trigger: 'axis',
		        confine: true,
		        axisPointer: {
		            animation: false
		        },
				formatter: function(params) {
					console.log(params);
				}
		    },
		    legend: {
		        data:[dataObj[objCode[0]].name],
		        top: 0,
        		x: 'center',
        		selectedMode:false,//取消图例上的点击事件,
		    },
		    toolbox: {
		        feature: {
		            dataZoom: {
		                yAxisIndex: 'none'
		            },
		            restore: {},
		            saveAsImage: {}
		        }
		    },
		    axisPointer: {
		        link: {xAxisIndex: 'all'}
		    },
		    dataZoom: [
		        {
		            show: true,
		            realtime: true,
		            start: 300,
		            end: 70,
		            xAxisIndex: [0]
		        },
		        {
		            type: 'inside',
		            realtime: true,
		            start: 300,
		            end: 70,
		            xAxisIndex: [0]
		        }
		    ],
		    grid: [{
		        left: 40,
		        right: 30,
		        height: '80%'
		    }],
		    xAxis : [
		        {
		            show: true,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataObj[objCode[0]].data
		        }
		    ],
		    yAxis : [
		        {
		            name : dataObj[objCode[0]].tUnit,
		            type : 'value',
//		            max : 500
		        }
		    ],
		    series : [
		        {
		            name:dataObj[objCode[0]].name,
		            type:'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            symbolSize: 8,
		            hoverAnimation: false,
		            data: dataObj[objCode[0]].data //[146.667,159.833,182.833,280.4,222.833,201.5,117,69.333,110.4,62,79.333,54.333,109.4,78,77.5,139.167,102]
		        }
		    ]
		};
		myChart.setOption(option);
	}
	//两幅图
	function Two_showChart(){
		var myChart = echarts.init(document.getElementById('chart'));
		option = {
		    title: {
//		        text: Title_Name1 + ' ' + Title_Name2 + ' ' + '对比图',
		        x: 'center'
		    },
		    tooltip: {
		        trigger: 'axis',
		        confine: true,
		        axisPointer: {
		            animation: false
		        }
		    },
		    legend: {
//      		show: false,
		        data:[E_Name1,E_Name2],
		        top: 0,
        		x: 'center',
        		selectedMode:false,//取消图例上的点击事件,
		    },
		    toolbox: {
		        feature: {
		            dataZoom: {
		                yAxisIndex: 'none'
		            },
		            restore: {},
		            saveAsImage: {}
		        }
		    },
		    axisPointer: {
		        link: {xAxisIndex: 'all'}
		    },
		    dataZoom: [
		        {
		            show: true,
		            realtime: true,
		            start: 300,
		            end: 70,
		            xAxisIndex: [0, 1]
		        },
		        {
		            type: 'inside',
		            realtime: true,
		            start: 300,
		            end: 70,
		            xAxisIndex: [0, 1]
		        }
		    ],
		    grid: [{
		        left: 33,
		        right: 30,
		        top: '6%',
		        height: '37%'
		    }, {
		        left: 33,
		        right: 30,
		        top: '53%',
		        height: '37%'
		    }],
		    xAxis : [
		        {
		            show: false,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataTimes1
		        },
		        {
		            show: true,
		            gridIndex: 1,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataTimes2,
		            // position: 'top'
		        }
		    ],
		    yAxis : [
		        {
		            name : Company1,
		            type : 'value',
//		            max : 500
		        },
		        {
		            gridIndex: 1,
		            name : Company2,
		            type : 'value',
		            inverse: false
		        }
		    ],
		    series : [
		        {
		            name: E_Name1,
                    smooth: true,
                    smoothMonotone: 'x',
		            type: 'line',
		            symbolSize: 8,
		            hoverAnimation: false,
		            data:dataValues1
		        },
		        {
		            name: E_Name2,
		            type: 'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            xAxisIndex: 1,
		            yAxisIndex: 1,
		            symbolSize: 8,
		            hoverAnimation: false,
		            data: dataValues2
		        }
		    ]
		};
		myChart.setOption(option);
	}
	//三幅图
	function Three_showChart(){
		var myChart = echarts.init(document.getElementById('chart'));
		
		
		option = {
		    title: {
//		        text:  Title_Name1 + ' ' + Title_Name2 + ' ' + Title_Name3 + ' ' + '对比图', 
		        x: 'center'
		    },
		    tooltip: {
		        trigger: 'axis',
		        confine: true,
		        axisPointer: {
		            animation: false
		        }
		    },
		    legend: {
//		        show: false,
		        data:[E_Name1,E_Name2,E_Name3],
		        top: 0,
        		x: 'center',
        		selectedMode:false,//取消图例上的点击事件,
		    },
		    toolbox: {
		        feature: {
		            dataZoom: {
		                yAxisIndex: 'none'
		            },
		            restore: {},
		            saveAsImage: {}
		        }
		    },
		    axisPointer: {
		        link: {xAxisIndex: 'all'}
		    },
		    dataZoom: [
		        {
		            show: true,
		            realtime: true,
		            start: 300,
		            end: 70,
		            xAxisIndex: [0, 1, 2]
		        },
		        {
		            type: 'inside',
		            realtime: true,
		            start: 300,
		            end: 70,
		            xAxisIndex: [0, 1, 2]
		        }
		    ],
		    grid: [{
		        left: 35,
		        right: 30,
		        top: '6%',
		        height: '23%'
		    }, {
		        left: 35,
		        right: 30,
		        top: '38%',
		        height: '23%'
		    }, {
		        left: 35,
		        right: 30,
		        top: '70%',
		        height: '23%'
		    }],
		    xAxis : [ 
		        {
		            show: false,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataTimes1
		        },
		        {
		            show: false,
		            gridIndex: 1,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataTimes2,
		            // position: 'top'
		        },
		        {
		            gridIndex: 2,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataTimes3,
		            // position: 'top'
		        }
		    ],
		    yAxis : [
		        {
		            name : Company1,
		            type : 'value',
//		            max : 500
		        },
		        {
		            gridIndex: 1,
		            name : Company2,
		            type : 'value',
		            inverse: false
		        },
		        {
		            gridIndex: 2,
		            name : Company3,
		            type : 'value',
		            inverse: false,
		        }
		    ],
		    series : [
		        {
		            name:E_Name1,
		            type:'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            symbolSize: 8,
		            hoverAnimation: false,
		            data:dataValues1
		        },
		        {
		            name:E_Name2,
		            type:'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            xAxisIndex: 1,
		            yAxisIndex: 1,
		            symbolSize: 8,
		            hoverAnimation: false,
		            data: dataValues2
		        },
		        {
		            name:E_Name3,
		            type:'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            xAxisIndex: 2,
		            yAxisIndex: 2,
		            symbolSize: 8,
		            hoverAnimation: false,
		            data: dataValues3
		        }
		    ]
		};
		myChart.setOption(option);
	}
	//四幅图
	function Four_showChart(){
		var myChart = echarts.init(document.getElementById('chart'));
		
		
		option = {
		    title: {
//		        text:  Title_Name1 + ' ' + Title_Name2 + ' ' + Title_Name3 + ' ' + Title_Name4,
		        x: 'center'
		    },
		    tooltip: {
		        trigger: 'axis',
		        confine: true,
		        axisPointer: {
		            animation: false
		        }
		    },
		    legend: {
//		        show: false,
		        data:[E_Name1,E_Name2,E_Name3,E_Name4],
		        top: 0,
        		x: 'center',
        		selectedMode:false,//取消图例上的点击事件,
		    },
		    toolbox: {
		        feature: {
		            dataZoom: {
		                yAxisIndex: 'none'
		            },
		            restore: {},
		            saveAsImage: {}
		        }
		    },
		    axisPointer: {
		        link: {xAxisIndex: 'all'}
		    },
		    dataZoom: [
		        {
		            show: true,
		            realtime: true,
		            start: 300,
		            end: 70,
		            xAxisIndex: [0, 1, 2, 3]
		        },
		        {
		            type: 'inside',
		            realtime: true,
		            start: 300,
		            end: 70,
		            xAxisIndex: [0, 1, 2, 3]
		        }
		    ],
		    grid: [{
		        left: 38,
		        right: 20,
		        top: '7%',
		        height: '17%'
		    }, {
		        left: 38,
		        right: 20,
		        top: '31%',
		        height: '17%'
		    }, {
		        left: 38,
		        right: 20,
		        top: '54%',
		        height: '17%'
		    }, {
		        left: 38,
		        right: 20,
		        top: '77%',
		        height: '17%'
		    }],
		    xAxis : [
		        {
		            show: false,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataTimes1
		        },
		        {
		            show: false,
		            gridIndex: 1,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataTimes2,
		        },
		        {
		            show: false,
		            gridIndex: 2,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataTimes3,
		            // position: 'top'
		        },
		        {
		            gridIndex: 3,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataTimes4, 
		            // position: 'top'
		        }
		    ],
		    yAxis : [
		        {
		            name : Company1,
		            type : 'value',
//		            max : 500
		        },
		        {
		            gridIndex: 1,
		            name : Company2,
		            type : 'value',
		            inverse: false
		        },
		        {
		            gridIndex: 2,
		            name : Company3,
		            type : 'value',
		            inverse: false,
		        },
		        {
		            gridIndex: 3,
		            name : Company4,
		            type : 'value',
		            inverse: false,
		        }
		    ],
		    series : [
		        {
		            name:E_Name1,
		            type:'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            symbolSize: 8,
		            hoverAnimation: false,
		            data:dataValues1
		        },
		        {
		            name:E_Name2,
		            type:'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            xAxisIndex: 1,
		            yAxisIndex: 1,
		            symbolSize: 8,
		            hoverAnimation: false,
		            data: dataValues2
		        },
		        {
		            name:E_Name3,
		            type:'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            xAxisIndex: 2,
		            yAxisIndex: 2,
		            symbolSize: 8,
		            hoverAnimation: false,
		            data: dataValues3
		        },
		        {
		            name:E_Name4,
		            type:'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            xAxisIndex: 3,
		            yAxisIndex: 3,
		            symbolSize: 8,
		            hoverAnimation: false,
		            data: dataValues4
		        }
		    ]
		};
		myChart.setOption(option);
	}
	//五幅图
	function Five_showChart(){
		var objCode = Object.keys(dataObj);
		var length = Object.keys(dataObj).length
		var myChart = echarts.init(document.getElementById('chart'));
		console.log(dataObj);
		
		option = {
		    title: {
//		        text:  Title_Name1 + ' ' + Title_Name2 + ' ' + Title_Name3 + ' ' + Title_Name4 + ' ' + Title_Name5,
		        x: 'center'
		    },
		    tooltip: {
		        trigger: 'axis',
		        confine: true,
		        axisPointer: {
		            animation: false
		        }
		    },
		    legend: {
//		        show: false,
		        data:[dataObj[objCode[0]].name,dataObj[objCode[1]].name,dataObj[objCode[2]].name,dataObj[objCode[3]].name,dataObj[objCode[4]].name],
		        top: 0,
        		x: 'center',
        		selectedMode:false,//取消图例上的点击事件,
		    },
		    toolbox: {
		        feature: {
		            dataZoom: {
		                yAxisIndex: 'none'
		            },
		            restore: {},
		            saveAsImage: {}
		        }
		    },
		    axisPointer: {
		        link: {xAxisIndex: 'all'}
		    },
		    dataZoom: [
		        {
		            show: true,
		            realtime: true,
		            start: 300,
		            end: 70,
		            xAxisIndex: [0, 1, 2, 3, 4]
		        },
		        {
		            type: 'inside',
		            realtime: true,
		            start: 300,
		            end: 70,
		            xAxisIndex: [0, 1, 2, 3, 4]
		        }
		    ],
		    grid: [{
		        left: 38,
		        right: 20,
		        top: '7%',
		        height: '13%'
		    }, {
		        left: 38,
		        right: 20,
		        top: '26%',
		        height: '13%'
		    }, {
		        left: 38,
		        right: 20,
		        top: '45%',
		        height: '13%'
		    }, {
		        left: 38,
		        right: 20,
		        top: '63%',
		        height: '13%'
		    }, {
		        left: 38,
		        right: 20,
		        top: '82%',
		        height: '13%'
		    }],
		    xAxis : [
		        {
		            show: false,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataObj[objCode[0]].data
		        },
		        {
		            show: false,
		            gridIndex: 1,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataObj[objCode[1]].data, 	
		        },
		        {
		            show: false,
		            gridIndex: 2,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataObj[objCode[2]].data,
		            // position: 'top'
		        },
		        {
		            show: false,
		            gridIndex: 3,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataObj[objCode[3]].data,
		            // position: 'top'
		        },
		        {
		            gridIndex: 4,
		            type : 'category',
		            boundaryGap : false,
		            axisLine: {onZero: true},
		            data: dataObj[objCode[4]].data,
		            // position: 'top'
		        }
		    ],
		    yAxis : [
		        {
		            name : dataObj[objCode[0]].tUnit,
		            type : 'value',
//		            max : 500
		        },
		        {
		            gridIndex: 1,
		            name : dataObj[objCode[1]].tUnit,
		            type : 'value',
		            inverse: false
		        },
		        {
		            gridIndex: 2,
		            name : dataObj[objCode[2]].tUnit,
		            type : 'value',
		            inverse: false,
		        },
		        {
		            gridIndex: 3,
		            name : dataObj[objCode[3]].tUnit,
		            type : 'value',
		            inverse: false,
		        },
		        {
		            gridIndex: 4,
		            name : dataObj[objCode[4]].tUnit,
		            type : 'value',
		            inverse: false,
		        }
		    ],
		    series : [
		        {
		            name:dataObj[objCode[0]].name,
		            type:'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            symbolSize: 8,
		            hoverAnimation: false,
		            data:dataObj[objCode[0]].data
		        },
		        {
		            name:dataObj[objCode[1]].name,
		            type:'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            xAxisIndex: 1,
		            yAxisIndex: 1,
		            symbolSize: 8,
		            hoverAnimation: false,
		            data: dataObj[objCode[1]].data
		        },
		        {
		            name:dataObj[objCode[2]].name,
		            type:'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            xAxisIndex: 2,
		            yAxisIndex: 2,
		            symbolSize: 8,
		            hoverAnimation: false,
		            data: dataObj[objCode[2]].data
		        },
		        {
		            name:dataObj[objCode[3]].name,
		            type:'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            xAxisIndex: 3,
		            yAxisIndex: 3,
		            symbolSize: 8,
		            hoverAnimation: false,
		            data: dataObj[objCode[3]].data
		        },
		        {
		            name:dataObj[objCode[4]].name,
		            type:'line',
                    smooth: true,
                    smoothMonotone: 'x',
		            xAxisIndex: 4,
		            yAxisIndex: 4,
		            symbolSize: 8,
		            hoverAnimation: false,
		            data: dataObj[objCode[4]].data
		        }
		    ]
		};
		myChart.setOption(option);
	}
	
	